\(\int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{a+i a \tan (c+d x)} \, dx\) [37]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [F(-2)]
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 34, antiderivative size = 101 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{a+i a \tan (c+d x)} \, dx=\frac {(A+3 i B) x}{2 a}+\frac {(i A-B) \log (\cos (c+d x))}{a d}-\frac {(A+3 i B) \tan (c+d x)}{2 a d}+\frac {(i A-B) \tan ^2(c+d x)}{2 d (a+i a \tan (c+d x))} \]

[Out]

1/2*(A+3*I*B)*x/a+(I*A-B)*ln(cos(d*x+c))/a/d-1/2*(A+3*I*B)*tan(d*x+c)/a/d+1/2*(I*A-B)*tan(d*x+c)^2/d/(a+I*a*ta
n(d*x+c))

Rubi [A] (verified)

Time = 0.14 (sec) , antiderivative size = 101, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.088, Rules used = {3676, 3606, 3556} \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{a+i a \tan (c+d x)} \, dx=\frac {(-B+i A) \tan ^2(c+d x)}{2 d (a+i a \tan (c+d x))}-\frac {(A+3 i B) \tan (c+d x)}{2 a d}+\frac {(-B+i A) \log (\cos (c+d x))}{a d}+\frac {x (A+3 i B)}{2 a} \]

[In]

Int[(Tan[c + d*x]^2*(A + B*Tan[c + d*x]))/(a + I*a*Tan[c + d*x]),x]

[Out]

((A + (3*I)*B)*x)/(2*a) + ((I*A - B)*Log[Cos[c + d*x]])/(a*d) - ((A + (3*I)*B)*Tan[c + d*x])/(2*a*d) + ((I*A -
 B)*Tan[c + d*x]^2)/(2*d*(a + I*a*Tan[c + d*x]))

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3606

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c - b
*d)*x, x] + (Dist[b*c + a*d, Int[Tan[e + f*x], x], x] + Simp[b*d*(Tan[e + f*x]/f), x]) /; FreeQ[{a, b, c, d, e
, f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]

Rule 3676

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_
.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[(-(A*b - a*B))*(a + b*Tan[e + f*x])^m*((c + d*Tan[e + f*x])^n/(2*a*f
*m)), x] + Dist[1/(2*a^2*m), Int[(a + b*Tan[e + f*x])^(m + 1)*(c + d*Tan[e + f*x])^(n - 1)*Simp[A*(a*c*m + b*d
*n) - B*(b*c*m + a*d*n) - d*(b*B*(m - n) - a*A*(m + n))*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f, A
, B}, x] && NeQ[b*c - a*d, 0] && EqQ[a^2 + b^2, 0] && LtQ[m, 0] && GtQ[n, 0]

Rubi steps \begin{align*} \text {integral}& = \frac {(i A-B) \tan ^2(c+d x)}{2 d (a+i a \tan (c+d x))}-\frac {\int \tan (c+d x) (2 a (i A-B)+a (A+3 i B) \tan (c+d x)) \, dx}{2 a^2} \\ & = \frac {(A+3 i B) x}{2 a}-\frac {(A+3 i B) \tan (c+d x)}{2 a d}+\frac {(i A-B) \tan ^2(c+d x)}{2 d (a+i a \tan (c+d x))}-\frac {(i A-B) \int \tan (c+d x) \, dx}{a} \\ & = \frac {(A+3 i B) x}{2 a}+\frac {(i A-B) \log (\cos (c+d x))}{a d}-\frac {(A+3 i B) \tan (c+d x)}{2 a d}+\frac {(i A-B) \tan ^2(c+d x)}{2 d (a+i a \tan (c+d x))} \\ \end{align*}

Mathematica [A] (verified)

Time = 1.39 (sec) , antiderivative size = 103, normalized size of antiderivative = 1.02 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{a+i a \tan (c+d x)} \, dx=\frac {\frac {4 B \tan ^2(c+d x)}{a+i a \tan (c+d x)}+\frac {(-3 i A+5 B) \log (i-\tan (c+d x))-(i A+B) \log (i+\tan (c+d x))-\frac {2 (A+3 i B)}{-i+\tan (c+d x)}}{a}}{4 d} \]

[In]

Integrate[(Tan[c + d*x]^2*(A + B*Tan[c + d*x]))/(a + I*a*Tan[c + d*x]),x]

[Out]

((4*B*Tan[c + d*x]^2)/(a + I*a*Tan[c + d*x]) + (((-3*I)*A + 5*B)*Log[I - Tan[c + d*x]] - (I*A + B)*Log[I + Tan
[c + d*x]] - (2*(A + (3*I)*B))/(-I + Tan[c + d*x]))/a)/(4*d)

Maple [A] (verified)

Time = 0.07 (sec) , antiderivative size = 125, normalized size of antiderivative = 1.24

method result size
norman \(\frac {\frac {\left (3 i B +A \right ) x}{2 a}+\frac {-i A +B}{2 a d}-\frac {\left (3 i B +A \right ) \tan \left (d x +c \right )}{2 a d}+\frac {\left (3 i B +A \right ) x \left (\tan ^{2}\left (d x +c \right )\right )}{2 a}-\frac {i B \left (\tan ^{3}\left (d x +c \right )\right )}{a d}}{1+\tan ^{2}\left (d x +c \right )}+\frac {\left (-i A +B \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 a d}\) \(125\)
derivativedivides \(-\frac {i B \tan \left (d x +c \right )}{d a}-\frac {A}{2 d a \left (\tan \left (d x +c \right )-i\right )}-\frac {i B}{2 d a \left (\tan \left (d x +c \right )-i\right )}-\frac {i A \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d a}+\frac {A \arctan \left (\tan \left (d x +c \right )\right )}{2 d a}+\frac {B \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d a}+\frac {3 i B \arctan \left (\tan \left (d x +c \right )\right )}{2 d a}\) \(133\)
default \(-\frac {i B \tan \left (d x +c \right )}{d a}-\frac {A}{2 d a \left (\tan \left (d x +c \right )-i\right )}-\frac {i B}{2 d a \left (\tan \left (d x +c \right )-i\right )}-\frac {i A \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d a}+\frac {A \arctan \left (\tan \left (d x +c \right )\right )}{2 d a}+\frac {B \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d a}+\frac {3 i B \arctan \left (\tan \left (d x +c \right )\right )}{2 d a}\) \(133\)
risch \(\frac {5 i x B}{2 a}+\frac {3 x A}{2 a}+\frac {{\mathrm e}^{-2 i \left (d x +c \right )} B}{4 a d}-\frac {i {\mathrm e}^{-2 i \left (d x +c \right )} A}{4 a d}+\frac {2 i B c}{a d}+\frac {2 A c}{a d}+\frac {2 B}{d a \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}-\frac {\ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) B}{a d}+\frac {i \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) A}{a d}\) \(140\)

[In]

int(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c)),x,method=_RETURNVERBOSE)

[Out]

(1/2*(A+3*I*B)*x/a+1/2/a/d*(-I*A+B)-1/2*(A+3*I*B)*tan(d*x+c)/a/d+1/2*(A+3*I*B)/a*x*tan(d*x+c)^2-I*B/a/d*tan(d*
x+c)^3)/(1+tan(d*x+c)^2)+1/2/a/d*(-I*A+B)*ln(1+tan(d*x+c)^2)

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 127, normalized size of antiderivative = 1.26 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{a+i a \tan (c+d x)} \, dx=\frac {2 \, {\left (3 \, A + 5 i \, B\right )} d x e^{\left (4 i \, d x + 4 i \, c\right )} + {\left (2 \, {\left (3 \, A + 5 i \, B\right )} d x - i \, A + 9 \, B\right )} e^{\left (2 i \, d x + 2 i \, c\right )} - 4 \, {\left ({\left (-i \, A + B\right )} e^{\left (4 i \, d x + 4 i \, c\right )} + {\left (-i \, A + B\right )} e^{\left (2 i \, d x + 2 i \, c\right )}\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) - i \, A + B}{4 \, {\left (a d e^{\left (4 i \, d x + 4 i \, c\right )} + a d e^{\left (2 i \, d x + 2 i \, c\right )}\right )}} \]

[In]

integrate(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c)),x, algorithm="fricas")

[Out]

1/4*(2*(3*A + 5*I*B)*d*x*e^(4*I*d*x + 4*I*c) + (2*(3*A + 5*I*B)*d*x - I*A + 9*B)*e^(2*I*d*x + 2*I*c) - 4*((-I*
A + B)*e^(4*I*d*x + 4*I*c) + (-I*A + B)*e^(2*I*d*x + 2*I*c))*log(e^(2*I*d*x + 2*I*c) + 1) - I*A + B)/(a*d*e^(4
*I*d*x + 4*I*c) + a*d*e^(2*I*d*x + 2*I*c))

Sympy [A] (verification not implemented)

Time = 0.31 (sec) , antiderivative size = 151, normalized size of antiderivative = 1.50 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{a+i a \tan (c+d x)} \, dx=\frac {2 B}{a d e^{2 i c} e^{2 i d x} + a d} + \begin {cases} \frac {\left (- i A + B\right ) e^{- 2 i c} e^{- 2 i d x}}{4 a d} & \text {for}\: a d e^{2 i c} \neq 0 \\x \left (- \frac {3 A + 5 i B}{2 a} + \frac {\left (3 A e^{2 i c} - A + 5 i B e^{2 i c} - i B\right ) e^{- 2 i c}}{2 a}\right ) & \text {otherwise} \end {cases} + \frac {x \left (3 A + 5 i B\right )}{2 a} + \frac {i \left (A + i B\right ) \log {\left (e^{2 i d x} + e^{- 2 i c} \right )}}{a d} \]

[In]

integrate(tan(d*x+c)**2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c)),x)

[Out]

2*B/(a*d*exp(2*I*c)*exp(2*I*d*x) + a*d) + Piecewise(((-I*A + B)*exp(-2*I*c)*exp(-2*I*d*x)/(4*a*d), Ne(a*d*exp(
2*I*c), 0)), (x*(-(3*A + 5*I*B)/(2*a) + (3*A*exp(2*I*c) - A + 5*I*B*exp(2*I*c) - I*B)*exp(-2*I*c)/(2*a)), True
)) + x*(3*A + 5*I*B)/(2*a) + I*(A + I*B)*log(exp(2*I*d*x) + exp(-2*I*c))/(a*d)

Maxima [F(-2)]

Exception generated. \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{a+i a \tan (c+d x)} \, dx=\text {Exception raised: RuntimeError} \]

[In]

integrate(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c)),x, algorithm="maxima")

[Out]

Exception raised: RuntimeError >> ECL says: expt: undefined: 0 to a negative exponent.

Giac [A] (verification not implemented)

none

Time = 0.47 (sec) , antiderivative size = 99, normalized size of antiderivative = 0.98 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{a+i a \tan (c+d x)} \, dx=\frac {\frac {{\left (-i \, A - B\right )} \log \left (\tan \left (d x + c\right ) + i\right )}{a} - \frac {{\left (3 i \, A - 5 \, B\right )} \log \left (\tan \left (d x + c\right ) - i\right )}{a} - \frac {4 i \, B \tan \left (d x + c\right )}{a} - \frac {-3 i \, A \tan \left (d x + c\right ) + 5 \, B \tan \left (d x + c\right ) - A - 3 i \, B}{a {\left (\tan \left (d x + c\right ) - i\right )}}}{4 \, d} \]

[In]

integrate(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c)),x, algorithm="giac")

[Out]

1/4*((-I*A - B)*log(tan(d*x + c) + I)/a - (3*I*A - 5*B)*log(tan(d*x + c) - I)/a - 4*I*B*tan(d*x + c)/a - (-3*I
*A*tan(d*x + c) + 5*B*tan(d*x + c) - A - 3*I*B)/(a*(tan(d*x + c) - I)))/d

Mupad [B] (verification not implemented)

Time = 7.77 (sec) , antiderivative size = 95, normalized size of antiderivative = 0.94 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{a+i a \tan (c+d x)} \, dx=-\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,\left (B+A\,1{}\mathrm {i}\right )}{4\,a\,d}-\frac {B\,\mathrm {tan}\left (c+d\,x\right )\,1{}\mathrm {i}}{a\,d}-\frac {\left (A+B\,1{}\mathrm {i}\right )\,1{}\mathrm {i}}{2\,a\,d\,\left (1+\mathrm {tan}\left (c+d\,x\right )\,1{}\mathrm {i}\right )}-\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )-\mathrm {i}\right )\,\left (-5\,B+A\,3{}\mathrm {i}\right )}{4\,a\,d} \]

[In]

int((tan(c + d*x)^2*(A + B*tan(c + d*x)))/(a + a*tan(c + d*x)*1i),x)

[Out]

- (log(tan(c + d*x) + 1i)*(A*1i + B))/(4*a*d) - (B*tan(c + d*x)*1i)/(a*d) - ((A + B*1i)*1i)/(2*a*d*(tan(c + d*
x)*1i + 1)) - (log(tan(c + d*x) - 1i)*(A*3i - 5*B))/(4*a*d)